/*     */ package com.iris.egrant.component.service;
/*     */ 
/*     */ import com.iris.egrant.component.dao.BaseComponentDao;
import com.iris.egrant.component.model.BaseComponent;
import com.iris.egrant.app.utils.IrisStringUtils;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Arrays;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Service;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @Service("baseComponentService")
/*     */ @Transactional(rollbackFor = {Exception.class})
/*     */ public class BaseComponentServiceImpl
/*     */   implements BaseComponentService
/*     */ {
/*     */   private static final long serialVersionUID = -897438875395235226L;
/*     */   @Autowired
/*     */   private BaseComponentDao baseComponentDao;
/*     */   
/*     */   public BaseComponent findBaseComponentByName(String key) {
/*  38 */     if (IrisStringUtils.isNullOrBlank(key)) {
/*  39 */       return null;
/*     */     }
/*  41 */     return this.baseComponentDao.findBaseComponentByName(key);
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public List<Map<String, Object>> findComponentData(BaseComponent baseComponent) {
/*  47 */     if (baseComponent == null) {
/*  48 */       return null;
/*     */     }
/*  50 */     String sql = baseComponent.getSql();
/*  51 */     if (IrisStringUtils.isNullOrBlank(sql)) {
/*  52 */       return null;
/*     */     }
/*  54 */     if (StringUtils.isNotBlank(baseComponent.getLocale())) {
/*  55 */       baseComponent.getSqlParamVal().put("locale", baseComponent.getLocale());
/*     */     }
/*  57 */     List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
/*  58 */     List<Object> params = new ArrayList();
///*  59 */     baseComponent.getSqlParamVal().put("psn_code", SecurityUtils.getCurrentUserId());
///*  60 */     baseComponent.getSqlParamVal().put("role_id", Integer.valueOf(SecurityUtils.getCurrentUserRoleId()));
///*  61 */     baseComponent.getSqlParamVal().put("psnCode", SecurityUtils.getCurrentUserId());
///*  62 */     baseComponent.getSqlParamVal().put("roleId", Integer.valueOf(SecurityUtils.getCurrentUserRoleId()));
///*  63 */     sql = SqlConverUtils.compress2RuledQl(sql, baseComponent.getSqlParamVal(), params);
/*  64 */     if (baseComponent.getKey() != null && baseComponent.getKey().equals("test_keyword2")) {
/*  65 */       String researchId = (String)baseComponent.getSqlParamVal().get("researchid");
/*  66 */       List<String> col = new ArrayList<String>();
/*  67 */       col.add("-1");
/*  68 */       col.addAll(Arrays.asList(researchId.split(",")));
/*  69 */       baseComponent.getSqlParamVal().put("researchid", col);
/*     */     } 
/*     */     
/*  72 */     List<Map<String, Object>> list = this.baseComponentDao.queryForListByMap(sql, baseComponent.getSqlParamVal());
/*  73 */     if (list == null) {
/*  74 */       return null;
/*     */     }
/*  76 */     result = toMap(list, baseComponent.getLocale());
/*  77 */     return result;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public List<Map<String, Object>> toMap(List<Map<String, Object>> maps, String locale) {
/*  88 */     List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
/*  89 */     for (Map<String, Object> map : maps) {
/*  90 */       Map<String, Object> mapTemp = new HashMap<String, Object>();
/*  91 */       mapTemp.put("id", map.get("ID"));
/*  92 */       Object name = null;
/*  93 */       if ("zh_CN".equals(locale)) {
/*  94 */         name = map.get("ZH_CN_NAME");
/*  95 */       } else if ("en_US".equals(locale)) {
/*  96 */         name = map.get("EN_US_NAME");
/*  97 */       } else if ("zh_TW".equals(locale)) {
/*  98 */         name = map.get("ZH_TW_NAME");
/*     */       } 
/* 100 */       if (name == null) {
/* 101 */         name = map.get("NAME");
/*     */       }
/* 103 */       mapTemp.put("name", name);
/* 104 */       mapTemp.put("pid", map.get("PID"));
/* 105 */       result.add(mapTemp);
/*     */     } 
/* 107 */     return result;
/*     */   }
/*     */ 
/*     */   
/*     */   public List<Map<String, Object>> findComponentDataByPId(BaseComponent baseComponent, String pid) {
/* 112 */     List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
/* 113 */     if (baseComponent == null) {
/* 114 */       return null;
/*     */     }
/* 116 */     if (IrisStringUtils.isNullOrBlank(pid)) {
/* 117 */       return null;
/*     */     }
/* 119 */     String sql = baseComponent.getSql();
/* 120 */     if (IrisStringUtils.isNullOrBlank(sql)) {
/* 121 */       return null;
/*     */     }
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 127 */     return result;
/*     */   }
/*     */ }


/* Location:              D:\文件kjt\WEB-INF\lib\egrant-core-2.2.20240205.1659.jar!\com\iris\egrant\component\service\BaseComponentServiceImpl.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */